package com.example.service;

import com.example.entity.Customer;
import com.example.mapper.CustomerMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerService {
    
    @Resource
    CustomerMapper customerMapper;

    public void add(Customer customer) {
        customerMapper.insert(customer);
    }

    public void deleteById(Integer id) {
        customerMapper.deleteById(id);
    }

    public void updateById(Customer customer) {
        customerMapper.updateById(customer);
    }

    public List<Customer> selectAll() {
        return customerMapper.selectAll();
    }

    public Customer selectById(Integer id) {
        return customerMapper.selectById(id);
    }

    public Customer selectByUserId(Integer id) {
        return customerMapper.selectByUserId(id);
    }
    public PageInfo<Customer> selectPage(Integer pageNum, Integer pageSize) {
        //开启分页查询
        PageHelper.startPage(pageNum, pageSize);
        List<Customer> list = customerMapper.selectAll();
        return PageInfo.of(list);
    }
}
